package com.yc.yc112plyqnzf.util;

import org.springframework.core.convert.converter.Converter;

import java.time.LocalDate;

public class DateConvertor implements Converter<String, LocalDate> {

    @Override
    public LocalDate convert(String source) {
        String[] split = source.split("\\D+");


        try{
            int year =Integer.parseInt(split[0]);
            int month =Integer.parseInt(split[1]);
            int day =Integer.parseInt(split[2]);
            return LocalDate.of(year,month,day);
        }catch (Exception e){
            e.printStackTrace();

            return null;
        }

    }
}
